/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.team1160.breakaway.camera;

import edu.wpi.first.wpilibj.image.EllipseMatch;
import edu.wpi.first.wpilibj.util.SortedVector.Comparator;

/**
 *
 * @author nttoole
 */
public class EllipseAreaComparator implements Comparator
{
    public int compare(Object obj1, Object obj2)
    {
        if (!(obj1 instanceof EllipseMatch))
            return 0;
        else if (!(obj2 instanceof EllipseMatch))
            return 0;

        EllipseMatch em1 = (EllipseMatch) obj1;
        EllipseMatch em2 = (EllipseMatch) obj2;

        double area1 = em1.m_majorRadius * em1.m_minorRadius;
        double area2 = em2.m_majorRadius * em2.m_minorRadius;

        if (area1 == area2)
            return 0;
        else if (area1 < area2)
            return -1;
        else
            return 1;

    }
    
}
